using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;

namespace Toolkit.Wrappers
{
    public class Audio
    {
        private Cue CueSound;
        private SoundBank soundBank;
        private AudioEngine audioEngine;
        private WaveBank waveBank;

        public bool Playing
        {
            get { return CueSound != null && CueSound.IsPlaying; }
        }

        public Audio(AudioEngine audioEngine, WaveBank waveBank, SoundBank soundBank)
        {
            this.audioEngine = audioEngine;
            this.waveBank = waveBank;
            this.soundBank = soundBank;
        }

        public void PlaySound(string soundName, bool looping)
        {
            if (soundBank != null && soundName != string.Empty)
            {
                if (looping)
                {
                    if (CueSound == null)
                    {
                        CueSound = soundBank.GetCue(soundName);
                        CueSound.Play();
                    }
                    else if (CueSound.IsPaused)
                        CueSound.Resume();
                }
                else
                    soundBank.PlayCue(soundName);
            }
        }

        public void PauseSound()
        {
            if (Playing)
                CueSound.Pause();
        }
    }
}